% figure base on the real data
function StanceLeg2DLeft(data,j)
    % position of all the points
    activeSensors = [0, 1, 4, 5, 6, 13, 14, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31];
    
%     clf;
%     hold on;
    x = data(j,3*activeSensors+1);
    y = data(j,3*activeSensors+2);
    %z = data(j,3*activeSensors+3);
    
    plot(x,y,'r.'); % the position of the sensors
    
    hold on;
    
%     set(gca,'DataAspectRatio',[1 1 1]);
%     axis([-1000,1000,-1200,400]);
%     plot3(x(end-12),z(end-12),y(end-12),'b.');    
%     set(gca,'DataAspectRatio',[1 1 1]);
    axis equal;
    % draw the line
    
    % draw the torso 
    xTorsoS = 1/2*(x(1)+x(2)); yTorsoS = 1/2*(y(1)+y(2));
    xTorsoE = 1/2*(x(3)+x(13)); yTorsoE = 1/2*(y(3)+y(13));
    line1 = line([xTorsoS xTorsoE],[yTorsoS yTorsoE],'color','k','erasemode', 'normal','LineWidth',2); 
    %line1 = line([x(2) x(1)],[y(2) y(1)],'color','b','erasemode', 'normal','LineWidth',2);
    %line2 = line([x(1) x(7)],[y(1) y(7)],'color','b','erasemode', 'normal','LineWidth',2);
%     line3 = line([x(7) x(3)],[y(7) y(3)],'color','b','erasemode', 'normal','LineWidth',2);
%     line4 = line([x(7) x(13)],[y(7) y(13)],'color','b','erasemode', 'normal','LineWidth',2);
    line5 = line([x(3) x(4)],[y(3) y(4)],'color','g','erasemode', 'normal','LineWidth',2);  % left thight
    line6 = line([x(13) x(14)],[y(13) y(14)],'color','b','erasemode', 'normal','LineWidth',2);
    disp('left knee')
    x(14)
    y(14)
    plot(x(14),y(14),'go')
    disp('left average ankle')
    mid_l_x = 1/2*(x(9)+x(11));mid_l_y = 1/2*(y(9)+y(11));
%     plot(mid_r_x,mid_r_y,'ko')
    mid_r_x = 1/2*(x(16)+x(18))
    mid_r_y = 1/2*(y(16)+y(18))
    plot(mid_r_x,mid_r_y,'ko')
    
    %%%%%%%%%%%
    atan((mid_r_x - x(14))/(mid_r_y-y(14)))
    
    %%%%%%%%%%%%
    line7 = line([x(4) mid_l_x],[y(4) mid_l_y],'color','g','erasemode', 'normal','LineWidth',2); % left calf
    line8 = line([x(14) mid_r_x],[y(14) mid_r_y],'color','b','erasemode', 'normal','LineWidth',2);
%     line9 = line([x(9) x(11)],[y(9) y(11)],'color','b','erasemode', 'normal','LineWidth',2);
%     line10 = line([x(16) x(18)],[y(16) y(18)],'color','b','erasemode', 'normal','LineWidth',2);
%     line11 = line([x(10) x(12)],[y(10) y(12)],'color','b','erasemode', 'normal','LineWidth',2);
%     line12 = line([x(17) x(19)],[y(17) y(19)],'color','b','erasemode', 'normal','LineWidth',2);
    
%     plot(z,y,'r.');
%     hold on
%     plot(z(end),y(end),'b.');    

%     grid on;
%     axis([zmin,zmax,xmin,xmax,ymin,ymax]);
%     xlabel('X');ylabel('Y');
  
%     view(3); 
%     view([90 0]); % for rot_humanData  front
%     view([0 0]); % side view
%     view([162+90,0])
%     hold on;
%   view([-136.5+180+90 0]); % for eff_humanData, walking to left
%   view([-136.5+180 0]); % for eff_humanData
%     pause(.2);
end